package model.semantics;

import model.State;
import model.semantics.Node;

/**
 * Represents a variable in the expression tree (e.g. "x".)
 * @author Sterling Dorminey
 */
public class VariableNode<T> extends Node<T> {

	private String myLabel;
	
	public VariableNode(String label) {
		myLabel = label;
	}
	
	@Override
	public T evaluate(State<T> state) {
		Node<T> child = state.getAssignment(myLabel);
		return child.evaluate(state);
	}
	
	@Override
	public String toString() {
		return myLabel;
	}
}
